package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class UserMenu {

    private PrintStream printStream;
    private BufferedReader reader;
    private List<String> loginOptions = Arrays.asList("Enter 1 to login as guest.", "Enter 2 to login as a member.");
    private List<String> guestMenuOptions = Arrays.asList("Enter 1 to view the list of all books.", "Enter 2 to view all movies.");
    private List<String> userMenuOptions = Arrays.asList("Enter 1 to view the list of all books.", "Enter 2 to view all movies.",
            "Enter 3 to check your membership details.", "Enter 4 to reserve a book.");
    public UserMenu(PrintStream printstream, BufferedReader reader) {
        this.printStream = printstream;
        this.reader = reader;
    }

    private String readUserInput() throws IOException {

        return reader.readLine();
    }

    public String printMenuOptions(Collection<String> menuOptions) throws IOException {
        for(String option : menuOptions){
            printStream.println(option);
        }
        return readUserInput();
    }

    public String printGuestMenuOptions() throws IOException {
        for (String option : guestMenuOptions) {
            printStream.println(option);
        }
        return readUserInput();
    }

    public String printLoginOptions() throws IOException {
        for (String option : loginOptions) {
            printStream.println(option);
        }
        return readUserInput();
    }

    public String printUserMenuOptions() throws IOException {
        for (String option : userMenuOptions) {
            printStream.println(option);
        }
        return readUserInput();
    }
}
